<?php
/*
	Template Name: Blog Page
*/
?>
<?php get_header(); ?>


<?php include (TEMPLATEPATH . '/framework/includes/get_pages_top.php'); ?>

<div class="page_container_bg">
	<div class="page_container clearfix">
	
		<div class="page_content">
			<div class="page_content_text">
				
					<?php if(have_posts()) : ?>
					
					<?php 
						$category_id =  get_post_meta($post->ID, "blog_id", true);
						$limit = get_post_meta($post->ID, "blog_limit", true);
						$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
						query_posts("cat=$category_id&showposts=$limit&paged=$paged");
						$i = 1;
						
						
						$height = get_post_meta($post->ID, "blog_thumb_height", true);
						$width = get_post_meta($post->ID, "blog_thumb_width", true);
						
						$padtop = $height/2 - 28;
						$padleft = $width/2 - 37;
					?>
					
					<?php while(have_posts()) : the_post(); ?>		
			
			
				<!-- begin blog container -->
				<div class="blog_container">
				
				
					<div class="blog_head">
						<div class="blog_title">
								<h2><?php the_title(); ?></h2>
						</div>
						<div class="cleardiv"></div>
							
						<div class="blog_info">	
							<ul>
								<li class="date_icon"><?php the_time('M j, Y'); ?></li>
								<li class="written_by">by <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><?php the_author() ?></a></li>
								<li class="category"><?php the_category(', ') ?></li>
								<li class="comment_icon"><?php comments_popup_link(get_option('cf_no_comments', 'No Comments').' &#187;', get_option('cf_one_comment', 'One Comment').' &#187;', '% '.get_option('cf_one_comments', 'Comments').' &#187;', 'commentslink', get_option('cf_off_comments', 'Comments Off')); ?></li>
							</ul>
							<?php if(get_the_tags()){ ?>
							<div class="blog_tag">
								<?php the_tags('<ul><li>',',</li><li>','</li></ul>'); ?>
							</div>
							<?php } ?>
						</div>
					</div>
					
					
						
						<?php if(get_post_meta($post->ID, "thumb_one", true) != "" or get_post_meta($post->ID, "video_one", true) != ""){ ?>
						<!-- begin box image -->
						<div class="blog_image">
							
							<div class="image_skin">
								<div class="image_inside_border">
								
									
										<?php if(get_post_meta($post->ID, "video_one", true) != ""){ ?>
									<!-- begin image -->
									<div class="image_skin_anime" style="width:<?php echo $width; ?>px;">
									
											<?php echo get_post_meta($post->ID, "video_one", true); ?>
									
											<?php } else { ?>
									<!-- begin image -->
									<div class="image_skin_anime" style="width:<?php echo $width; ?>px; height:<?php echo $height; ?>px;">
															
											
											<div class="image_holder" id="<?php 
														$type = get_post_meta($post->ID, "big_one", true);
														$type =  substr($type, -4);
														if(get_post_meta($post->ID, "big_one", true) != ""){ 
															if($type == ".jpg" or $type == ".gif" or $type == ".png" or $type == ".jpeg" or $type == ".JPG" or $type == ".GIF" or $type == ".PNG" or $type == ".JPEG") { echo "zoom_image"; } else { echo "zoom_play"; }
														}
													?>" style="width:<?php echo $width; ?>px; height:<?php echo $height; ?>px;">
											
											<?php if(get_post_meta($post->ID, "big_one", true) != ""){ ?>
												<a href="<?php echo get_post_meta($post->ID, "big_one", true); ?>" rel="prettyPhoto[canyon_gallery]">
											<?php } ?>
											
											<?php if(get_post_meta($post->ID, "big_one", true) == "" && get_post_meta($post->ID, "short_desc", true) != ""){ ?>
												<a href="<?php the_permalink() ?>">
											<?php } ?>
											
											
											<img src="<?php echo get_post_meta($post->ID, "thumb_one", true); ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>" alt=""/>
											
											<?php if(get_post_meta($post->ID, "big_one", true) != ""){ ?>
											</a>
											<?php }  ?>
											
											<?php if(get_post_meta($post->ID, "big_one", true) == "" && get_post_meta($post->ID, "short_desc", true) != ""){ ?>
												</a>
											<?php } ?>
											
											</div>
											
											
											<?php }  ?>
									
									</div>
									<!-- end image -->
									
								</div>
							</div>
							
						</div>
						<?php } ?>
				
					
					
					
					<!-- begin detail text -->
					<div class="blog_text">
					
						<?php if (get_post_meta($post->ID, "short_desc", true) != "") { ?>
						<div class="blog_short_text">						
						<?php echo get_post_meta($post->ID, "short_desc", true); ?>
						</div>
						<div class="blog_detail_button">
							<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
								<span class="details_button">
									<?php echo get_option('site_read_more', 'Read more &#187;'); ?>
								</span>
							</a>
						</div>
						<?php } else { ?>

						<?php the_content(); ?>
						
						<?php } ?>
						
					</div>
					<!-- begin detail text -->
			
			
				</div>
				<!-- end blog container -->
			
			
			<?php endwhile; endif; ?>
			
			
			
			
			<div class="page_nav_numbers">
			
				<?php include (TEMPLATEPATH . '/framework/includes/get_pagination.php'); ?>

			</div>
				
				
				
			</div>
		</div>
		
		<div class="page_right_content">
			<?php 
				wp_reset_query();
				if($post->post_parent) {
					$children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->post_parent."&echo=0");
				} else {
					$children = wp_list_pages("title_li=&sort_column=menu_order&child_of=".$post->ID."&echo=0");
				}
				if ($children) { 
			?>
			<div class="page_right_navigation">
				
				<?php wp_reset_query(); if(intval($post->post_parent)>0){	while(intval($post->post_parent)>0)	$post = get_post($post->post_parent);	} echo "<h3>".get_the_title($post->post_parent)."</h3>"; wp_reset_query(); ?>

					
				<!-- begin navigation categories -->
				<ul>
					<?php wp_reset_query(); echo create_page($post);?>
				</ul>
				<!-- begin navigation categories -->

			</div>
			<?php } ?>
			
			<div class="page_right_sidebars">	
				<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('Blog Sidebars')) {} else { } ?>
				<?php get_sidebar(); ?>
			</div>
			
		</div>

	</div>
</div>



<?php get_footer(); ?>
